home *** CD-ROM | disk | FTP | other *** search
- 19Sep90/1115 Subject: dove telemetrie programm (info) de DH8BAG @ DB0HB
-
- Nachdem es mir neulich gelungen ist, mit einfachsten Mitteln ein paar Telemetrie-
- blöcke von DO-17 aufzufangen, habe ich mich drangesetzt und ein Dekoder-
- Programm geschrieben. Einige Programme, die ich aus der Box geholt hatte,
- wollten aus irgendwelchen Gründen nicht so, wie ich wollte.
- Nachdem eine Anzeige im Textmode schnell fertig war, bin ich daran gegangen
- und habe mir als Gag eine Anzeige auf simulierten Analoginstrumenten aus-
- gedacht.
- Aus Portabilitätsgründen habe ich mich für die BGI Grafik entschieden. die
- Geschichte sollte also auch ungefähr auf dem PC und seinen Brüdern laufen.
- aber das Überschreiben des Meβwerts führt beim PC nicht dazu, daβ der alte
- Text gelöscht wird ... zumindest hier muβ man noch was tun ...
- Das ganze besteht aus drei Files:
- 1.) dovetlm.c - das Hauptprogramm
- 2.) analog.c - Unterprogramme für die Analog-Instrumente
- 3.) analog.h - das Header-File dazu
- Wer gefallen an meinen "Analog" Instrumenten findet, darf sie gerne für andere
- Zwecke "miβbrauchen".
- 73 und viel Spaβ damit
- Guido (DH8BAG @ DB0HB)
-
- 19Sep90/1117 Subject: dove tlm 1/3 de DH8BAG @ DB0HB
-
- /* File analog.h */
- typedef struct {
- int x,y;
- char unit[10];
- int a,e;
- int cx,cy;
- double val;
- char remark[20];
- } INSTRUMENT;
-
- void init_inst(INSTRUMENT *,int,int,char *,int,int,char *);
- void draw_inst(INSTRUMENT *);
- void update_inst(INSTRUMENT *,double);
-
- 19Sep90/1136 Subject: dove tlm 2/3 de DH8BAG @ DB0HB
-
- /* File analog.c */
- #include <cport.h>
- #include <graphics.h>
- #include <ext.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
- #include "analog.h"
-
- void init_inst(INSTRUMENT *in,int x,int y,char *u,int a,int e,char *rem)
- {
- in->x=x;
- in->y=y;
- strcpy(in->unit,u);
- in->a=a;
- in->e=e;
- in->cx=x+60;
- in->cy=y+70;
- in->val=0.0;
- if (rem)
- strcpy(in->remark,rem);
- else
- strcpy(in->remark,"");
- }
-
- void draw_inst(INSTRUMENT *in)
- {
- int angl;
- double u,v;
- int i;
- char s[10],help[30];
- int skalen_end_wert;
- int faktor=1;
-
- rectangle(in->x,in->y,in->x+120,in->y+82);
- outtextxy(in->cx-4*strlen(in->remark),in->y+84,in->remark);
- arc(in->cx,in->cy,45,135,50);
- sprintf(help,"%6.2f %s",in->val,in->unit);
- outtextxy(in->cx-4*strlen(help),in->y+65,help);
- skalen_end_wert=in->e;
- while (skalen_end_wert>20) {
- skalen_end_wert/=10;
- faktor*=10;
- }
- if (faktor>1)
- sprintf(help,"%s (*%d)",in->unit,faktor);
- else strcpy(help,in->unit);
- outtextxy(in->cx-strlen(help)*4,in->y+40,help);
- for(i=0;i<=skalen_end_wert;i++) {
- angl=135-((int)i*90*faktor/in->e);
- u=cos(angl*M_PI/180.0);
- v=sin(angl*M_PI/180.0);
- if (i%5 && !(skalen_end_wert < 5))
- line((int)in->cx+u*50,(int)in->cy-v*50,(int)in->cx+u*55,(int)in->cy-v*55);
- else {
- line((int)in->cx+u*50,(int)in->cy-v*50,(int)in->cx+u*60,(int)in->cy-v*60);
- itoa(i,s,10);
- outtextxy((int)in->cx+u*69-4*strlen(s),(int)in->cy-v*69,s);
- }
- }
- setwritemode(XOR_PUT);
- angl=135-(int)(in->val*0.9);
- u=cos(angl*M_PI/180.0);
- v=sin(angl*M_PI/180.0);
- line(in->cx,in->cy,(int)in->cx+u*57,(int)in->cy-v*57);
- }
-
- void update_inst(INSTRUMENT *in,double val)
- {
- int angl;
- double u,v;
- char help[30];
-
- setwritemode(COPY_PUT);
- sprintf(help,"%6.2f %s",val,in->unit);
- outtextxy(in->cx-4*strlen(help),in->y+65,help);
- setwritemode(XOR_PUT);
- angl=135-(int)(fabs(in->val)*90.0/in->e);
- u=cos(angl*M_PI/180.0);
- v=sin(angl*M_PI/180.0);
- line(in->cx,in->cy,(int)in->cx+u*57,(int)in->cy-v*57);
- in->val=val;
- setwritemode(XOR_PUT);
- angl=135-(int)(fabs(in->val)*90.0/in->e);
- if (angl>135) angl=135;
- if (angl<45) angl=45;
- u=cos(angl*M_PI/180.0);
- v=sin(angl*M_PI/180.0);
- line(in->cx,in->cy,(int)in->cx+u*57,(int)in->cy-v*57);
- }
-
- 19Sep90/1147 Subject: dove tlm 3/3 de DH8BAG @ DB0HB
-
- /* File dovetlm.c */
- #include <stdio.h>
- #include <string.h>
- #include <assert.h>
- #include <analog.h>
- #include <graphics.h>
- #include <stdlib.h>
- #include <ext.h>
- #include <math.h>
- #include <tos.h>
-
- #define TELEMETRIE "dove_2.tlm"
- #define exp10(a) pow(10,a)
-
- INSTRUMENT inst[58];
- int valid[58];
-
- typedef struct {
- char name[16];
- double c,b,a;
- char unit[7];
- } TLM_ENTRY;
-
- static TLM_ENTRY tlm[] = {
-
- "Rx E/F Audio(W)",0,0.0246,0,"V(p-q)",
- "Rx E/F Audio(N)",0,0.0246,0,"V(p-q)",
- "Mixer Bias V" ,0,0.0102,0,"Volts",
- "Osc. Bisd V" ,0,0.0102,0,"Volts",
- "Rx A Audio (W)" ,0,0.0246,0,"V(p-q)",
- "Rx A Audio (N)" ,0,0.0246,0,"V(p-p)",
- "Rx A DISC" ,10.427,-0.09274,0,"kHz",
- "Rx A S meter" ,0,1,0,"Counts",
- "Rx E/F DISC" ,9.6234,-0.09911,0,"kHz",
- "Rx E/F S meter" ,0,1,0,"Counts",
- "+5Volt Bus" ,0,0.0305,0,"Volts",
- "+5V Rx Current" ,0,0.0001,0,"Amps",
- "+2.5V VREF" ,0,0.0108,0,"Volts",
- "8.5V BUS" ,0,0.0391,0,"Volts",
- "IR Detector" ,0,1,0,"Counts",
- "LO Monitor I" ,0,0.000037,0,"Amps",
- "+10V BUS" ,0,0.05075,0,"Volts",
- "GASFET Bias I" ,0,0.000026,0,"Amps",
- "Ground REF" ,0,0.01,0,"Volts",
- "+Z Array V" ,0,0.10230,0,"Volts",
- "RX Temp" ,101.05,-0.6051,0,"Deg. C",
- "+X (RX) temp" ,101.05,-0.6051,0,"Deg. C",
- "Bat 1 V" ,1.7932,-0.0034084,0,"Volts",
- "Bat 2 V" ,1.7978,-0.0035316,0,"Volts",
- "Bat 3 V" ,1.8046,-0.0035723,0,"Volts",
- "Bat 4 V" ,1.7782,-0.0034590,0,"Volts",
- "Bat 5 V" ,1.8410,-0.0038355,0,"Volts",
- "Bat 6 V" ,1.8381,-0.0038450,0,"Volts",
- "Bat 7 V" ,1.8568,-0.0037757,0,"Volts",
- "Bat 8 V" ,1.7868,-0.0034068,0,"Volts",
- "Array V" ,7.2050,0.0720,0,"Volts",
- "+5V Bus" ,1.9320,0.0312,0,"Volts",
- "+8.5V Bus" ,5.2650,0.0173,0,"Volts",
- "+10V Bus" ,7.4690,0.021765,0,"Volts",
- "BCR Set Point" ,-8.7620,1.1590,0,"Counts",
- "BCR Load Cur" ,-0.0871,0.00698,0,"Amps",
- "+8.5V Bus Cur" ,-0.00920,0.001899,0,"Amps",
- "+5V Bus Cur" ,0.00502,0.00431,0,"Amps",
- "-X Array Cur" ,-0.01075,0.00215,0,"Amps",
- "+X Array Cur" ,-0.01349,0.00270,0,"Amps",
- "-Y Array Cur" ,-0.01196,0.00239,0,"Amps",
- "+Y Array Cur" ,-0.01141,0.00228,0,"Amps",
- "-Z Array Cur" ,-0.01653,0.00245,0,"Amps",
- "+Z Array Cur" ,-0.01137,0.00228,0,"Amps",
- "Ext Power Cur" ,-0.02000,0.00250,0,"Amps",
- "BCR Input Cur" ,0.06122,0.00317,0,"Amps",
- "BCR Output Cur" ,-0.01724,0.00345,0,"Amps",
- "Bat 1 Temp" ,101.05,-0.6051,0,"Deg. C",
- "Bat 2 Temp" ,101.05,-0.6051,0,"Deg. C",
- "Baseplt Temp" ,101.05,-0.6051,0,"Deg. C",
- "FM TX#1 RF OUT" ,0.0256,-0.000884,0.0000836,"Watts",
- "FM TX#2 RF OUT" ,-0.0027,0.001257,0.0000730,"Watts",
- "PSK TX HPA Temp",101.05,-0.6051,0,"Deg. C",
- "+Y Array Temp" ,101.05,-0.6051,0,"Deg. C",
- "RC PSK HPA Temp",101.05,-0.6051,0,"Deg. C",
- "RC PSK BP Temp" ,101.05,-0.6051,0,"Deg. C",
- "+Z Array Temp" ,101.05,-0.6051,0,"Deg. C",
- "S band TX Out" ,-0.0451,0.00403,0,"Watts",
- "S band HPA Temp",101.05,-0.6051,0,"Deg. C"
- };
-
- FILE *in;
- char *cursym; /* das aktuelle symbol */
-
- char *scan(char *t) /* liefert das nächste token */
- {
- char *p;
-
- static char buffer[100]="";
-
- p=strtok(NULL,t);
- while (p==NULL)
- {
- if (fgets(buffer,100,in)==NULL)
- {
- fclose(in);
- getch();
- exit(0);
- }
- p=strtok(buffer,t);
- }
- cursym=p;
- return(p);
- }
-
- void rest(void) /* überliest "ctl UI pid F0\n" */
- {
- assert(!strcmp(cursym,"ctl"));
- scan(" ");
- assert(!strcmp(cursym,"UI"));
- scan(" ");
- assert(!strcmp(cursym,"pid"));
- scan(" \n");
- assert(!strcmp(cursym,"F0"));
- scan(" \n");
- }
-
- void s7(void) /* Dekodiert TLM */
- {
- int addr,value;
- double val_real;
- rest();
- while(strlen(cursym)==5 && cursym[2]==':')
- {
- sscanf(cursym,"%x:%x",&addr,&value);
- val_real=(value*value)*tlm[addr].a+value*tlm[addr].b+tlm[addr].c;
- if (valid[addr])
- update_inst(&inst[addr],val_real);
- scan(" \n");
- }
- }
-
- void s6(void) /* Dekodiert TIME-1 */
- {
- rest();
- scan("\n");
- /* printf("%s\n",cursym); */
- scan(" \n");
- }
-
- void s5(void) /* Dekodiert WASH */
- {}
-
- void s4(void) /* Dekodiert LSTAT */
- {}
-
- void s3(void) /* Dekodiert STATUS */
- {}
-
- void s2(void) /* Sucht Zielrufzeichen */
- {
- while(!strcmp(cursym,"to"))
- scan(" ");
- if (!strcmp(cursym,"STATUS")) {
- scan(" ");
- s3();
- }
- if (!strcmp(cursym,"LSTAT")) {
- scan(" ");
- s4();
- }
- if (!strcmp(cursym,"WASH")) {
- scan(" ");
- s5();
- }
- if (!strcmp(cursym,"TIME-1")) {
- scan(" ");
- s6();
- }
- if (!strcmp(cursym,"TLM")) {
- scan(" ");
- s7();
- }
- }
-
- void s1(void) /* Prüft auf "DOVE-1" */
- {
- if (!strcmp(cursym,"DOVE-1")) {
- scan(" ");
- s2();
- }
- }
-
- void s0(void) /* sucht "fm" als Anfang des Monitorheaders */
- {
- while (1) {
- scan(" ");
- if (!strcmp(cursym,"fm")) {
- scan(" ");
- s1();
- }
- }
- }
-
- void init(void)
- {
- int i;
- int max;
- double help,factor;
- int n=0;
-
- if ((in=fopen(TELEMETRIE,"r"))==NULL)
- {
- perror("Error");
- exit(errno);
- }
- /* in=stdaux für realtime anzeige der daten vom tnc */
- for (i=0;i<58;i++)
- valid[i]=0;
- for (i=0;i<58 && n < 20;i++) {
- help=tlm[i].a*256.0*256.0; /* Die folgenden Zeilen versuchen einen */
- help+=tlm[i].b*256.0; /* vernüftigen Skalenendwert zu berechnen */
- help+=tlm[i].c;
- help=fabs(help);
- factor=floor(log10(help));
- help/=exp10(factor);
- help=ceil(help);
- help*=exp10(factor);
- max=(int)help;
- if (max > 1)
- {
- init_inst(&inst[i],10+125*(n%5),99*(n/5),tlm[i].unit,0,max,tlm[i].name);
- draw_inst(&inst[i]);
- valid[i]=1;
- n++;
- }
- }
- }
-
- /* Das Telemetriefile wird mit einem "Deterministischen Endlichen *
- * Automaten" (kurz DEA) analysiert. Es werden Daten im Monitorformat *
- * der WA8DED/TF erwartet. Es werden nur die Blöcke an "TLM" aus- *
- * gewertet und nur die ersten zwanzig. Dieses Programm ist auch nur *
- * als Anregung gedacht und hat sicherlich die Überarbeitung nötig */
-
- void main(void)
- {
- int graphdriver = DETECT, /* automatische */
- graphmode; /* Erkennung */
-
- initgraph(&graphdriver, &graphmode, "\TC");
- atexit(closegraph);
- init();
- s0();
- exit(0);
- }
-
-